package com.example.tutorial.java.concurrent.practice.ch12;

import java.util.HashSet;
import java.util.Set;

/**
 * @author: cph
 * @date: 2022-5-7
 */
public class ConcurrentTestCase {
    public static void main(String[] args) {
        Set set = new HashSet<>();

        int count = 1000;
        for (int i = 0; i < count; i++) {
            set.add(xorShift(i));
        }

        System.out.println(set.size());
    }

    /**
     * 伪随机数生成器
     *
     * @param y
     * @return
     */
    static int xorShift(int y) {
        y ^= (y << 6);
        y ^= (y >>> 21);
        y ^= (y << 7);
        return y;
    }
}
